<?php
include_once("header.php");
?>
<?php
$domain=$_POST["domain"];
if(empty($domain)) {
?>
<form method='post' action='domain_new.php'>
	<h3>Domain name:</h3>
	<input type='text' name='domain' size='40'>
	<br><br>
	<input type='submit' value='Create domain'>
</form>
<?php
}
else {
	$query=mysql_query("SELECT domain FROM domains WHERE domain='$domain'");
	$nDomain=mysql_num_rows($query);
	if($nDomain < 1)
	{
		$addDomain=mysql_query("INSERT INTO `domains` (`domain`) VALUES ('$domain');");
		$affDomain=mysql_affected_rows();
		if($affDomain == 1) {echo "<h3>Domain Created!</h3><br>Now, you can <a href='user_add.php'>create new user <img src='images/add.png' border='0'>
</a>";} else {echo "Please contact your System Admin - ERROR: domain_new.php";}
	}
	else {echo "<h3>ERROR</h3><br>Domain <b>$domain</b> exist!";}

}
echo "<br /><br />";
include_once("domain/list_domains_div.php");
?>
<br /><br />
<br /><br />
<?php
include_once("footer.php");
?>
